from sqlalchemy import Column, Integer, String, Text, ForeignKey
from sqlalchemy.orm import relationship

from models import Base

class Article(Base):
    """
        文章信息
    """
    __tablename__ = "article"
    id = Column(Integer, primary_key=True,autoincrement=True)
    title = Column(String(50),nullable=False,comment="名称")
    content = Column(Text,comment="内容")
    # author_id和author用于表示一对多的关系
    author_id=Column(Integer,ForeignKey('student.id'),comment="作者，外键关联student.id")
    author=relationship("Student",backref="articles")
